package com.leo;

import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.ContentDisplay;
import javafx.scene.control.ListCell;
import javafx.scene.layout.HBox;

/**
 * @ClassName MyListCell
 * @Description
 * @Author wangss
 * @date 2020.05.25 23:05
 * @Version 1.0
 */
public class MyListCell extends ListCell<String> {

    @Override
    protected void updateItem(String item, boolean empty) {
        super.updateItem(item, empty);

        if (!empty) {
            HBox box = new HBox();
            box.getChildren().addAll(new Button(item), new Button("hello"));
            box.setStyle("-fx-background-color: #e7eeea");
            box.setAlignment(Pos.CENTER);

            this.setStyle("-fx-background-color: #09b6ff");
            this.setAlignment(Pos.CENTER);
            this.setContentDisplay(ContentDisplay.CENTER);
            this.setGraphic(box);
        }
    }
}
